<%--
    Document   : rechercherStage
    Created on : 19-mars-2014, 0:40:22
    Author     : Lionel
--%>


<%@page import="model.StageMapped" %>
<%@page import="java.util.Calendar" %>
<%@page import="java.util.List" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%Calendar now = Calendar.getInstance();%>
<%! List<StageMapped> stagews;%>
<% stagews = (List<StageMapped>) request.getAttribute("listeStages");%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css"
          href="<%=request.getContextPath()%>/assets/css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/assets/css/Site.css"/>
    <link rel="stylesheet" type="text/css"
          href="<%=request.getContextPath()%>/assets/css/animation.css"/>
    <link rel="stylesheet" type="text/css"
          href="<%=request.getContextPath()%>/assets/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css"
          href="<%=request.getContextPath()%>/assets/css/bootstrap-theme.css"/>
    <link rel="stylesheet" type="text/css"
          href="<%=request.getContextPath()%>/assets/css/bootstrap-theme.min.css"/>
    <script src="<%=request.getContextPath()%>/assets/js/jquery-1.10.2.js"></script>
    <script src="<%=request.getContextPath()%>/assets/js/jquery-1.10.2.min.js"></script>
    <!--   <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
       <script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>-->
    <script type="text/javascript" src="<%=request.getContextPath()%>/assets/js/bootstrap.min.js"></script>
    <title>Rechercher un stage</title>
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
    <div class="navbar j navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <span class="icon-bar"></span> <span class="icon-bar"></span> <span
                    class="icon-bar"></span>

                <a class="navbar-brand" href="<%=request.getContextPath()%>" lang="fr">Adventure
                    Sports</a>
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li><a href="<%=request.getContextPath()%>"><span class="glyphicon glyphicon-home">&nbsp;</span>Accueil
                    </a></li>
                    <li><a href="#">À propos de</a></li>
                    <li><a href="<%=request.getContextPath()%>/Site/Contact/contact.jsp"><span
                            class="glyphicon glyphicon-info-sign">&nbsp;</span>Contact</a>
                    </li>
                    <li class="dropdown"><a href="#" class="dropdown-toggle"
                                            data-toggle="dropdown">Activité <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                            <li><a href="#"><span class="glyphicon glyphicon-eye-open">&nbsp;</span>Consulter</a></li>
                        </ul>
                    </li>
                    <li class="dropdown"><a href="#" class="dropdown-toggle"
                                            data-toggle="dropdown">Stage <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?id=0"><span
                                    class="glyphicon glyphicon-search">&nbsp;</span>Rechercher</a>
                            </li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?nouveaute=0"><span
                                    class="glyphicon glyphicon-flash">&nbsp;</span>Nouveautées</a>
                            </li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?promo=0"><span
                                    class="glyphicon glyphicon-exclamation-sign">&nbsp;</span>Promo
                                (Last minute)</a></li>
                        </ul>
                    </li>
                </ul>

                <ul class="nav navbar-nav navbar-right">
                    <li><a href="<%=request.getContextPath()%>/Account/signin.jsp"><span
                            class="glyphicon glyphicon-pencil">&nbsp;</span>S'inscrire</a>
                    </li>
                    <% if (session.getAttribute("user") == null) { %>
                    <li><a href="<%=request.getContextPath()%>/Account/login.jsp"><span
                            class="glyphicon glyphicon-log-in">&nbsp;</span>Se connecter</a></li>
                    <% }  else { %>
                    <li><a href="<%= request.getContextPath()%>/CustomerManagerServlet?action=logout"><span
                            class="glyphicon glyphicon-log-out">&nbsp;</span>Se déconnecter</a>
                        <% }%>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</nav>

<div class="container body-content">
    <div class="jumbotron">
        <h1 class="h1" style="text-decoration: underline;">
            Rechercher un stage
        </h1>
        <h2 class="h2 text-success">  <marquee  scrollamount="10" scrolldelay="0">Choisissez votre stage parmis les nombreux proposé utilsez les différents critères pour mieux choisir</marquee></h2>

    </div>
    <div class="recherche panel panel-info" style="padding-bottom: 25px; padding-left: 25px;">
        <h3 class="h3" style="text-decoration: underline;">Critère de recherche:</h3>
        <table>
            <tr>
                <td>
                    <div class="btn-group">
                        <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown">
                            Durée du stage <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="./StageManagerServlet?jour=1">1 jour</a></li>
                            <li class="divider"></li>
                            <li><a href="./StageManagerServlet?jour=2">2 jours</a></li>
                        </ul>
                    </div>
                </td>
                <td style="padding-left: 25px;">
                    <div class="btn-group">
                        <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown">
                            Prix <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?id=0">Tous les prix</a>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?price=-25"><25 €</a></li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?price=25-50">25-50 €</a></li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?price=50-100">50-100 €</a>
                            </li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?price=100-150">100-150 €</a>
                            </li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?price=>150">>150 €</a></li>
                        </ul>
                    </div>
                </td>
                <td style="padding-left: 25px;">
                    <div class="btn-group">
                        <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown">
                            Activité <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="#">Activité1</a></li>
                            <li class="divider"></li>
                            <li><a href="#">Activité2</a></li>
                            <li class="divider"></li>
                            <li><a href="#">Activité3</a></li>
                            <li class="divider"></li>
                            <li><a href="#">Activité4</a></li>
                        </ul>
                    </div>
                </td>
                <td style="padding-left: 25px;">
                    <div class="btn-group">
                        <button type="button" class=" btn btn-info dropdown-toggle" data-toggle="dropdown">
                            Age minimum <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?age=-10"> moins de 10 ans</a>
                            </li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?age=10"> à partir de 10
                                ans</a></li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?age=10-12"> entre 10 et 12
                                ans</a></li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?age=12">à partir de 12
                                ans</a></li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?age=12-16"> entre 12 et 16
                                ans</a></li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?age=16"> à partir de 16
                                ans</a></li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?age=16-18">entre 16 et 18
                                ans</a></li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?age=18">à partir de 18
                                ans</a></li>
                        </ul>
                    </div>
                </td>
                <td style="padding-left: 25px;">
                    <div class="btn-group">
                        <button type="button" class=" btn btn-info dropdown-toggle" data-toggle="dropdown">
                            Niveau <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?level=1">Niveau 1</a></li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?level=2">Niveau 2</a></li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?level=3">Niveau 3</a></li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?level=4">Niveau 4</a></li>
                            <li class="divider"></li>
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?level=5">Niveau 5</a></li>
                        </ul>
                    </div>

                </td>
                <td style="padding-left: 25px;">
                    <div class="btn-group">
                        <button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown">Liens vers
                            <span class="caret"></span></button>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="<%=request.getContextPath()%>/StageManagerServlet?promo=0">Promo</a></li>
                        </ul>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <div class="recherchePromo panel panel-info" style="padding-bottom: 25px; padding-left: 25px;">
        <h3 class="h3" style="text-decoration: underline;">Critère de recherche pour les promotions et last minute:</h3>
        <table>
            <td style="padding-left: 25px;">
                <div class="btn-group">
                    <button type="button" class=" btn btn-info dropdown-toggle" data-toggle="dropdown">
                        Nombre de place restante (Last minutes) <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu" role="menu">
                        <li><a href="<%=request.getContextPath()%>/StageManagerServlet?promo=1"> plus qu'une place</a>
                        </li>
                        <li class="divider"></li>
                        <li><a href="<%=request.getContextPath()%>/StageManagerServlet?promo=<5">moins de 5 places</a>
                        </li>
                        <li class="divider"></li>
                        <li><a href="<%=request.getContextPath()%>/StageManagerServlet?promo=<10">moins de 10 places</a>
                        </li>
                        <li class="divider"></li>
                    </ul>
                </div>
            </td>
            <td style="padding-left: 25px;">
                <div class="btn-group">
                    <button type="button" class=" btn btn-info dropdown-toggle" data-toggle="dropdown">
                        Promotions <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu" role="menu">
                        <li><a href="<%=request.getContextPath()%>/StageManagerServlet?promo=1-<50">Stage de 1 jours à
                            moins de 50 EUR</a></li>
                        <li class="divider"></li>
                        <li><a href="<%=request.getContextPath()%>/StageManagerServlet?promo=1-<100">Stage de 1 jours à
                            moins de 100 EUR</a></li>
                        <li class="divider"></li>
                        <li><a href="<%=request.getContextPath()%>/StageManagerServlet?promo=2-<50">Stage de 2 jours à
                            moins de 50 EUR</a></li>
                        <li class="divider"></li>
                        <li><a href="<%=request.getContextPath()%>/StageManagerServlet?promo=2-<100">Stage de 2 jours à
                            moins de 100 EUR</a></li>
                        <li class="divider"></li>
                    </ul>
                </div>
            </td>
            <td style="padding-left: 25px;">
                <div class="btn-group">
                    <button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown">Liens vers
                        <span class="caret"></span></button>
                    <ul class="dropdown-menu" role="menu">
                        <li><a href="<%=request.getContextPath()%>/StageManagerServlet?id=0">Liste des stages</a></li>
                    </ul>
                </div>
            </td>

        </table>
    </div>
</div>

<div class="container bs-example">
    <h1 class="h1 text-warning" style="text-decoration: underline">Liste des stages: </h1>
    <table class=" table table-bordered table-hover">
        <thead>
        <tr class="text-danger">
            <th>Inscription</th>
            <th>Label</th>
            <th>Description</th>
            <th>Durée du stage</th>
            <th>Niveaux</th>
            <th>Age minimum</th>
            <th>Prix</th>
            <th>Fin des inscriptions</th>
            <%--<th>RegistrationMax</th>--%>
            <th>Date de début</th>
            <th>Place restante</th>
        </tr>
        </thead>

        <div class="test"></div>
        <input id="nouveaute" type="hidden"
               value="<% if (request.getAttribute("nouveaute")!=null )out.print( request.getAttribute("nouveaute").toString());%>"/>
        <input id="critere" type="hidden"
               value="<% if (request.getAttribute("critere")!=null )out.print( request.getAttribute("critere").toString());%>"/>
        <input id="promo" type="hidden"
               value="<%if (request.getAttribute("promo")!=null) out.print(request.getAttribute("promo").toString());%>"/>

        <% for (int i = Integer.parseInt(request.getAttribute("start").toString()); i < Integer.parseInt(request.getAttribute("end").toString()); i++) {%>
        <tr>
            <% if (stagews.get(i).getRegistrationAvailable() != 0) {%>
            <td>
                <a href="<%= request.getContextPath()%>/RegistrationServlet?id=<%= stagews.get(i).getSportrainingID()%>"><span
                        class="glyphicon glyphicon-pencil"></span>S'inscrire</a></td>
            <%} else {%>
            <td><span class="glyphicon glyphicon-remove"></span>Ce stage est complet !</td>
            <%}%>
            <td>
                <%=stagews.get(i).getLabel()%>
            </td>
            <td>
                <%=stagews.get(i).getDescription()%>
            </td>
            <td>
                <%=stagews.get(i).getDuration() + "&nbspjour(s)"%>
            </td>
            <td>
                <%=stagews.get(i).getLevel()%>
            </td>
            <td>
                <%=stagews.get(i).getMinAge() + "&nbspans"%>
            </td>
            <td>
                <%=stagews.get(i).getPrice() + "&euro;"%>
            </td>
            <td>
                <%=stagews.get(i).getRegitrationDateLine()%>
            </td>
            <%--<td>--%>
            <%--<%=stage.getRegistrationMax()%>--%>
            <%--</td>--%>
            <td>
                <%=stagews.get(i).getStartDate()%>
            </td>
            <td style="background-color: <%if(stagews.get(i).getRegistrationAvailable()==0) out.print("red"); else out.print("white");%>">
                <%=stagews.get(i).getRegistrationAvailable()%>
            </td>
        </tr>
        <%
            }%>
    </table>
    <div class="container"><span class="text-warning">
                                <strong><%=request.getAttribute("end").toString() + " sur " + stagews.size()%>
                                    stage(s)</strong></span>
    </div>
    <% String oldStartStr = request.getAttribute("start").toString();
        int oldStart = Integer.parseInt(oldStartStr) - 10;
        String oldEndStr = request.getAttribute("end").toString();
        int oldEnd = Integer.parseInt(oldEndStr) - 10;
    %>
    <ul class="pager">
        <li class="previous <%if (oldStart+10==0) out.print("disabled");%>"><a
                href="##" <%if (oldStart + 10 != 0) {%> onclick="history.go(-1);return false;"<%}%>>&larr;
            Précédent</a></li>
        <% if (request.getQueryString().contains("start")) {%>
        <li class="next <% if (oldEnd+10==stagews.size()) out.print("disabled");%> "><a
                href="<%=request.getContextPath()%>/StageManagerServlet?<%=request.getQueryString().replace("start="+oldStart,"start="+request.getAttribute("start").toString()).replace("end="+oldEnd,"end="+request.getAttribute("end").toString())%>">Suivant &rarr;</a>
        </li>
        <%} else {%>
        <li class="next  <% if (oldEnd+10==stagews.size()) out.print("disabled");%>"><a
                href="<%=request.getContextPath()%>/StageManagerServlet?<%=request.getQueryString()+"&start="+request.getAttribute("start")+"&end="+request.getAttribute("end")%>">Suivant &rarr;</a>
        </li>

        <%}%>
    </ul>

</div>

<hr/>

</div>
<footer class="fixed-bottom">
    <table style="width: 100%;">
        <tr>
            <td valign="middle" style="text-align: left">
            <td valign="bottom"
                style="text-decoration: underline; text-align: center;">
                Copyright <% out.print(now.get(Calendar.YEAR));%>
                Adventure Sports &copy; v0.1.0 by <span style="color: red;">Le Groupe Rouge</span>
            </td>
            <td valign="middle" style="text-align: right"></td>
        </tr>

    </table>

</footer>
<hr>
</body>
</html>
<script>

    $(document).ready(function () {
        $(".recherchePromo").hide();
        var textPromo = document.getElementsByTagName("input")[2].value.toString();
        var textAlert = document.getElementsByTagName("input")[1].value.toString();
        var textNouveaute = document.getElementsByTagName("input")[0].value.toString();
        if (textPromo == "promo") {
            $(".recherche").hide();
            $(".recherchePromo").show();
        }
        if (textNouveaute == "nouveaute") {
            $(".recherche").hide();
        }
        $(".test").append('<div id="alert" class="alert alert-success">' + textAlert + '</div>');


    });
</script>